#include<cstdio>
#include<iostream>
using namespace std;
int n,r;
int vis[22],chart[22];
void dfs(int num,int pre)
{
	if(num==r)
	{
		for(int i=1;i<=r;i++)
		{
			cout<<chart[i]<<" ";
		}
		cout<<endl;
		return;
	}
	for(int i=pre+1;i<=n;i++)
	{
		if(!vis[i])
		{
			vis[i]=1;
			chart[num+1]=i;
			dfs(num+1,i);
			vis[i]=0;
		}
	}
}
int main()
{
	cin>>n>>r;
	dfs(0,0);
}
